home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 14103 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.0 KB  |  35 lines

  1. Newsgroups: comp.lang.c
  2. Path: gail.ripco.com!mambuhl
  3. From: mambuhl@ripco.com (Martin Ambuhl)
  4. Subject: Re: Q:Hex to Decimal?    
  5. Message-ID: <DpqLyJ.8Jy@rci.ripco.com>
  6. X-Nntp-Sender: mambuhl@golden.ripco.com
  7. Sender: usenet@rci.ripco.com (Net News Admin)
  8. Organization: Ripco Internet BBS Chicago
  9. Date: Fri, 12 Apr 1996 06:56:43 GMT
  10.  
  11. Thomas A Cooper <tacooper@tricon.net> in <316D2289.4759@tricon.net>
  12. asks:
  13.  
  14. >I saw in a magazine a simple function to convert a HEX string to an
  15. >integer:
  16.  
  17. #define FAR     /* to make the following compilable */
  18. #define PASCAL
  19.  
  20. >long int FAR PASCAL hex2int(char far *s)
  21. >{
  22. >     return strtol(s,NULL,16);
  23. >}
  24.  
  25. > I'm struggling with the reverse situation, a function to convert an
  26. >integer into a HEX string. Anybody got any ideas?? Thanks in advance for
  27. >your help.
  28.  
  29.         sprintf(target_string,"x",(unsigned)your_integer);
  30.  
  31.                                                                                                                     
  32. --
  33. * Martin Ambuhl       net: mambuhl@ripco.com
  34. * Chicago, IL (USA)    
  35.